/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package kitaplaner.application;

import java.sql.Connection;
import java.util.ArrayList;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import kitaplaner.database.Gruppe;
import kitaplaner.database.Kita;

/**
 *
 * @author kristina
 */
public class LeitungApp {
    Kita kita;
    StatusApp stApp;
    GruppenApp grpApp;
    Connection conn;

    public LeitungApp(Kita kita, Connection conn)
    {
        this.kita = kita;
        this.conn = conn;
        stApp = new StatusApp(kita, conn);
        grpApp = new GruppenApp(kita, conn);
    }

    public DefaultTableModel createLeitOverview()
    {
        String[] columnNames = {"Gruppe",
                                "Std"};
        ArrayList <Gruppe> grp = kita.getGrp();
        
        DefaultTableModel model = new DefaultTableModel();
        JTable table = new JTable(model);

        //insert Columns
        for (int i = 0 ; i < columnNames.length; i++)
        {
            model.addColumn(columnNames[i]);
        }

        for (int i = 0; i < grp.size(); i++)
        {
            Object []obj = {grp.get(i).getName(), grp.get(i).getLeitZeit()};
            model.insertRow (model.getRowCount(), obj);
        }

        return model;
    }
}
